home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office deutch / INFOPATH.NL-NL / INFLR.CAB / TRAVELRE.XSN_1043 / merge.xsl < prev    next >
Extensible Markup Language  |  2006-11-12  |  7KB  |  152 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:agg="http://schemas.microsoft.com/office/infopath/2003/aggregation" xmlns:mergeUI="http://schemas.microsoft.com/office/infopath/2003/aggregation-mergeUI" xmlns:targetDoc="http://schemas.microsoft.com/office/infopath/2003/aggregation-target" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xdActionTable="http://schemas.microsoft.com/office/infopath/2003/aggregation-actionTable" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-21T21:12:27" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
  3. <xsl:output method="xml" encoding="utf-8" />
  4. <xsl:variable name="targetRoot" select="targetDoc:get-documentElement()" />
  5. <xsl:template match="/my:travelRequest">
  6. <xsl:copy>
  7. <xsl:apply-templates select="@*|node()" />
  8. </xsl:copy>
  9. </xsl:template>
  10. <xsl:template match="@*|node()">
  11. <xsl:param name="hasMatch" />
  12. <xsl:param name="targetParent" />
  13. <xsl:param name="targetXPath" />
  14. <xsl:copy>
  15. <xsl:choose>
  16. <xsl:when test="$targetParent">
  17. <xsl:variable name="thisName" select="name()" />
  18. <xsl:apply-templates select="@*|node()">
  19. <xsl:with-param name="hasMatch" select="$hasMatch" />
  20. <xsl:with-param name="targetParent" select="$targetParent/node()[name()=$thisName]" />
  21. <xsl:with-param name="targetXPath" select="concat($targetXPath, '/', name())" />
  22. </xsl:apply-templates>
  23. </xsl:when>
  24. <xsl:otherwise>
  25. <xsl:apply-templates select="@*|node()">
  26. <xsl:with-param name="hasMatch" select="$hasMatch" />
  27. </xsl:apply-templates>
  28. </xsl:otherwise>
  29. </xsl:choose>
  30. </xsl:copy>
  31. </xsl:template>
  32. <xsl:template match="/my:travelRequest/my:purpose">
  33. <xsl:param name="targetParent" select="$targetRoot/." />
  34. <xsl:call-template name="concatenateNonRepeatingFields">
  35. <xsl:with-param name="targetNode" select="$targetParent/my:purpose" />
  36. <xsl:with-param name="separator">
  37. <xsl:value-of disable-output-escaping="yes" select="", "" />
  38. </xsl:with-param>
  39. <xsl:with-param name="ignoreBlankFields" select="1" />
  40. </xsl:call-template>
  41. </xsl:template>
  42. <xsl:template match="/my:travelRequest/my:notes">
  43. <xsl:param name="targetParent" select="$targetRoot/." />
  44. <xsl:call-template name="concatenateNonRepeatingFields">
  45. <xsl:with-param name="targetNode" select="$targetParent/my:notes" />
  46. <xsl:with-param name="prefix">
  47. <FONT color="#808080" xmlns="http://www.w3.org/1999/xhtml">
  48. <STRONG>
  49. <xsl:value-of select="concat("[", ../my:name, ": ", ../my:purpose, "]")" />
  50. </STRONG>
  51. </FONT>
  52. </xsl:with-param>
  53. <xsl:with-param name="separator">
  54. <HR xmlns="http://www.w3.org/1999/xhtml" />
  55. </xsl:with-param>
  56. <xsl:with-param name="ignoreBlankFields" select="1" />
  57. </xsl:call-template>
  58. </xsl:template>
  59. <xsl:template name="concatenateNonRepeatingFields">
  60. <xsl:param name="targetNode" />
  61. <xsl:param name="prefix" />
  62. <xsl:param name="separator" />
  63. <xsl:param name="ignoreBlankFields" />
  64. <xsl:if test="not($ignoreBlankFields) or normalize-space(.) != ''">
  65. <xsl:copy>
  66. <xsl:attribute name="agg:action">replace</xsl:attribute>
  67. <xsl:copy-of select="$targetNode/@*" />
  68. <xsl:if test="not($ignoreBlankFields) or normalize-space($targetNode) != ''">
  69. <xsl:copy-of select="$targetNode/node()" />
  70. <xsl:copy-of select="$separator" />
  71. </xsl:if>
  72. <xsl:copy-of select="$prefix" />
  73. <xsl:copy-of select="node()" />
  74. </xsl:copy>
  75. </xsl:if>
  76. </xsl:template>
  77. <xsl:template name="insertRepeating">
  78. <xsl:param name="elementName" />
  79. <xsl:param name="targetNode" />
  80. <xsl:param name="order" />
  81. <xsl:param name="removeBlanks" />
  82. <xsl:param name="prefix" />
  83. <xsl:if test="not($removeBlanks) or normalize-space(.) != '' or .//@*[not(namespace-uri()="http://www.w3.org/2001/XMLSchema-instance" or starts-with(name(), "xml:"))][normalize-space(.)!='']">
  84. <xsl:copy>
  85. <xsl:if test="$order='before' and $targetNode">
  86. <xsl:attribute name="agg:order">before</xsl:attribute>
  87. <xsl:attribute name="agg:selectChild">
  88. <xsl:value-of select="concat($elementName, '[1]')" />
  89. </xsl:attribute>
  90. </xsl:if>
  91. <xsl:copy-of select="@*" />
  92. <xsl:if test="not($removeBlanks) or normalize-space(.) != ''">
  93. <xsl:copy-of select="$prefix" />
  94. <xsl:copy-of select="node()" />
  95. </xsl:if>
  96. </xsl:copy>
  97. </xsl:if>
  98. </xsl:template>
  99. <xsl:template name="matchRepeating">
  100. <xsl:param name="elementName" />
  101. <xsl:param name="targetNode" />
  102. <xsl:param name="targetNodeMatch" />
  103. <xsl:param name="targetXPath" />
  104. <xsl:param name="order" />
  105. <xsl:variable name="attributeList">
  106. <xsl:choose>
  107. <xsl:when test="$targetNodeMatch">
  108. <elementName agg:action="mergeAttributes" agg:select="{$targetXPath}" />
  109. </xsl:when>
  110. <xsl:otherwise>
  111. <elementName>
  112. <xsl:if test="$order='before' and $targetNode">
  113. <xsl:attribute name="agg:order">before</xsl:attribute>
  114. <xsl:attribute name="agg:selectChild">
  115. <xsl:value-of select="concat($elementName, '[1]')" />
  116. </xsl:attribute>
  117. </xsl:if>
  118. </elementName>
  119. </xsl:otherwise>
  120. </xsl:choose>
  121. </xsl:variable>
  122. <xsl:copy>
  123. <xsl:copy-of select="msxsl:node-set($attributeList)/*/@*" />
  124. <xsl:copy-of select="@*" />
  125. <xsl:apply-templates select="@*|node()">
  126. <xsl:with-param name="hasMatch" select="true()" />
  127. <xsl:with-param name="targetParent" select="$targetNodeMatch" />
  128. <xsl:with-param name="targetXPath" select="$targetXPath" />
  129. </xsl:apply-templates>
  130. </xsl:copy>
  131. </xsl:template>
  132. <xsl:template name="concatenateAttribute">
  133. <xsl:param name="targetAttribute" />
  134. <xsl:param name="prefix" />
  135. <xsl:param name="separator" />
  136. <xsl:param name="ignoreBlankFields" />
  137. <xsl:if test="not($ignoreBlankFields) or normalize-space(.) != ''">
  138. <xsl:attribute name="{name()}">
  139. <xsl:if test="not($ignoreBlankFields) or normalize-space($targetAttribute) != ''">
  140. <xsl:value-of select="$targetAttribute" />
  141. <xsl:copy-of select="$separator" />
  142. </xsl:if>
  143. <xsl:value-of select="$prefix" />
  144. <xsl:value-of select="." />
  145. </xsl:attribute>
  146. </xsl:if>
  147. </xsl:template>
  148. <xsl:template name="ActionTable">
  149. <xdActionTable:actionTable sourceRoot="/my:travelRequest"><xdActionTable:actions><xdActionTable:action enabled="1" type="4"><xdActionTable:source relativeXPath="my:purpose" parentRelativeXPath="." QName="my:purpose" /><xdActionTable:concatenate xhtml="0"><xdActionTable:ignoreBlankFields>1</xdActionTable:ignoreBlankFields><xdActionTable:separator type="2"><![CDATA[, ]]></xdActionTable:separator></xdActionTable:concatenate></xdActionTable:action><xdActionTable:action enabled="1" type="4"><xdActionTable:source relativeXPath="my:notes" parentRelativeXPath="." QName="my:notes" /><xdActionTable:concatenate xhtml="1"><xdActionTable:ignoreBlankFields>1</xdActionTable:ignoreBlankFields><xdActionTable:separator type="8"><HR xmlns="http://www.w3.org/1999/xhtml" /></xdActionTable:separator><xdActionTable:prefix type="formula"><FONT color="#808080" xmlns="http://www.w3.org/1999/xhtml"><STRONG>concat("[", ../my:name, ": ", ../my:purpose, "]")</STRONG></FONT></xdActionTable:prefix></xdActionTable:concatenate></xdActionTable:action></xdActionTable:actions></xdActionTable:actionTable>
  150. </xsl:template>
  151. </xsl:stylesheet>
  152.